/**
 * Customer model
 */
package data.converter.model;

import java.io.IOException;
import java.io.Writer;
import java.util.LinkedHashMap;

import org.json.simple.JSONStreamAware;
import org.json.simple.JSONValue;

public class Customer implements JSONStreamAware{

	private char type;
	private String customerCode;
	private String name;
	
	private Address address; 
	private Person primaryContact;
	
	public char getType() {
		return type;
	}
	
	public void setType(char type) {
		this.type = type;
	}
	
	public String getCustomerCode() {
		return customerCode;
	}

	public void setCustomerCode(String customerCode) {
		this.customerCode = customerCode;
	}

	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public Address getAddress() {
		return address;
	}
	
	public void setAddress(Address address) {
		this.address = address;
	}
	
	public Person getPrimaryContact() {
		return primaryContact;
	}
	
	public void setPrimaryContact(Person primaryContact) {
		this.primaryContact = primaryContact;
	}
	
	public void writeJSONString(Writer out){
		LinkedHashMap obj = new LinkedHashMap();
		obj.put("customerCode", customerCode);
		obj.put("name", name);
		obj.put("address", address);
		obj.put("primaryContact", primaryContact);
		try {
			JSONValue.writeJSONString(obj, out);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
